<template>
    <view class="container data-v-0eb2e4ce" :style="'background-size: 100% auto; background-repeat: no-repeat; background-image: url(+bgImage+);'">
        <navigator class="data-v-0eb2e4ce" url="/pages/rule/index?type=zhuli">
            <view class="float-btn rule global-shadow data-v-0eb2e4ce" hoverClass="hover">
                <image class="data-v-0eb2e4ce" mode="aspectFill" src="/static/static/smallBox/rule.png"></image>
                <text class="data-v-0eb2e4ce">规则</text>
            </view>
        </navigator>
        <view class="card data-v-0eb2e4ce">
            <view class="sku-c data-v-0eb2e4ce">
                <image class="thumb data-v-0eb2e4ce" mode="widthFix" :src="sku.thumb"></image>
                <view class="right data-v-0eb2e4ce">
                    <view class="title data-v-0eb2e4ce">{{ sku.title }}</view>
                    <view class="stock data-v-0eb2e4ce">{{ '剩' + sku.stock + '份 / 共' + sku.stock + sku.sales + '份' }}</view>
                </view>
            </view>
            <view class="title-2 data-v-0eb2e4ce" v-if="!launchRecord.id">快来助力吧，奖品先到先得~</view>
            <block v-else>
                <view class="user-c data-v-0eb2e4ce">
                    <image class="headimg data-v-0eb2e4ce" mode="widthFix" :src="launchRecord.user.headimg"></image>
                    <view class="right data-v-0eb2e4ce">
                        <view class="name data-v-0eb2e4ce">{{ launchRecord.user.name + '发起的助力' }}</view>
                        <view class="time data-v-0eb2e4ce">{{ $root.g0 }}</view>
                    </view>
                </view>
                <view class="status-c data-v-0eb2e4ce">
                    <view class="data-v-0eb2e4ce" v-if="launchRecord.union_status === 'working'">{{ '还差' + launchRecord.still_need_support_total + '个助力' }}</view>
                    <block v-else>
                        <view class="closed data-v-0eb2e4ce" v-if="launchRecord.union_status === 'closed'">已失效</view>
                        <block v-else>
                            <view class="completed data-v-0eb2e4ce" v-if="launchRecord.union_status === 'completed'">已完成</view>
                        </block>
                    </block>
                </view>
                <view class="count-down data-v-0eb2e4ce" v-if="launchRecord.union_status === 'working'">
                    <count-down @__l="__l" class="data-v-0eb2e4ce" :start="launchRecord.end_at" theme="zhuli" vueId="184912b1-1"></count-down>
                </view>
            </block>
            <block v-if="launchRecord.id">
                <block v-if="!launchRecord.is_author">
                    <block v-if="!launchRecord.is_supporter">
                        <button
                            @tap="__e"
                            class="launch-btn bg-red data-v-0eb2e4ce"
                            :data-event-opts="[['tap', [['disableMultiClick', ['$0'], ['createSupport']]]]]"
                            v-if="launchRecord.union_status === 'working'"
                        >
                            帮他/她助力
                        </button>
                        <button @tap="__e" class="launch-btn bg-red data-v-0eb2e4ce" :data-event-opts="[['tap', [['disableMultiClick', ['$0'], ['launchActivity']]]]]" v-else>
                            发起助力
                        </button>
                    </block>
                    <block v-else>
                        <button
                            @tap="__e"
                            class="launch-btn bg-red data-v-0eb2e4ce"
                            :data-event-opts="[['tap', [['disableMultiClick', ['$0'], ['launchActivity']]]]]"
                            v-if="info.union_status === 'working'"
                        >
                            已助力，我也要发起助力
                        </button>
                        <button class="launch-btn bg-gray data-v-0eb2e4ce" v-else>活动已结束</button>
                    </block>
                </block>
                <button @tap="__e" class="launch-btn bg-red data-v-0eb2e4ce" :data-event-opts="[['tap', [['disableMultiClick', ['$0'], ['sharePage']]]]]" v-else>转发给朋友</button>
            </block>
            <button @tap="__e" class="launch-btn bg-red data-v-0eb2e4ce" :data-event-opts="[['tap', [['disableMultiClick', ['$0'], ['launchActivity']]]]]" v-else>发起助力</button>
            <view class="rule-desc data-v-0eb2e4ce" v-if="info.score_price">
                支付
                <label class="_span data-v-0eb2e4ce" style="color: red">{{ info.score_price + scoreAlias }}</label>
                可发起助力
            </view>
            <view class="tips data-v-0eb2e4ce">
                <text class="new-iconfont icon-tips data-v-0eb2e4ce"></text>
                <label class="_span data-v-0eb2e4ce">{{ '需在' + info.time_limit + '小时内集齐' + info.need_user_total + '个助力' }}</label>
                <label @tap="__e" class="my-record-link _span data-v-0eb2e4ce" :data-event-opts="[['tap', [['checkMyRecord', ['$event']]]]]">我的记录</label>
            </view>
            <view class="text-btn-c data-v-0eb2e4ce">
                <label
                    @tap="__e"
                    class="text-btn launch-limit _span data-v-0eb2e4ce"
                    :data-event-opts="[['tap', [['checkLaunchUserGroup', ['$event']]]]]"
                    v-if="info.launch_user_group_id"
                >
                    查看发起条件
                </label>
                <label
                    @tap="__e"
                    class="text-btn support-limit second _span data-v-0eb2e4ce"
                    :data-event-opts="[['tap', [['checkSupportUserGroup', ['$event']]]]]"
                    v-if="info.support_user_group_id"
                >
                    查看助力条件
                </label>
            </view>
            <view class="bottom data-v-0eb2e4ce">
                <view class="left data-v-0eb2e4ce">
                    助力
                    <view class="_br data-v-0eb2e4ce"></view>
                    记录
                </view>
                <view class="right data-v-0eb2e4ce">
                    <image class="headimg data-v-0eb2e4ce" mode="widthFix" :src="item.headimg" v-for="(item, index) in userList" :key="index"></image>
                </view>
            </view>
        </view>
        <page-render @__l="__l" class="data-v-0eb2e4ce" :fullPageMode="false" :page="info.page" vueId="184912b1-2" v-if="info.page"></page-render>
        <my-record-list
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^select', [['selectLaunchRecord']]],
                        ['^close', [['e0']]]
                    ]
                })
            "
            @close="
                __e($event, {
                    eventOpts: [
                        ['^select', [['selectLaunchRecord']]],
                        ['^close', [['e0']]]
                    ]
                })
            "
            @select="
                __e($event, {
                    eventOpts: [
                        ['^select', [['selectLaunchRecord']]],
                        ['^close', [['e0']]]
                    ]
                })
            "
            class="data-v-0eb2e4ce"
            :data-event-opts="[
                ['^select', [['selectLaunchRecord']]],
                ['^close', [['e0']]]
            ]"
            :info="info"
            vueId="184912b1-3"
            v-if="isShowMyRecordList"
        ></my-record-list>
        <user-group-check
            @__l="__l($event, { eventOpts: [['^close', [['e1']]]] })"
            @close="__e($event, { eventOpts: [['^close', [['e1']]]] })"
            class="data-v-0eb2e4ce"
            :data-event-opts="[['^close', [['e1']]]]"
            :title="userGroupTitle"
            :userGroupId="userGroupId"
            vueId="184912b1-4"
            v-if="isShowUserGroupCheck"
        ></user-group-check>
        <share-popup
            @__l="__l($event, { eventOpts: [['^close', [['e2']]]] })"
            @close="__e($event, { eventOpts: [['^close', [['e2']]]] })"
            class="data-v-0eb2e4ce"
            :data-event-opts="[['^close', [['e2']]]]"
            :info="posterInfo"
            vueId="184912b1-5"
            v-if="isSharePopup"
        ></share-popup>
    </view>
</template>

<script>
import countDown from '@/components/CountDown/CountDown';
import pageRender from '@/components/PageRender/PageRender';
import userGroupCheck from '@/components/UserGroupCheck/UserGroupCheck';
import sharePopup from '@/components/SharePopup/SharePopup';
import myRecordList from '@/pages/zhuli/components/MyRecordList';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/zhuli/detail'],
    {
        '084b': function (t, e, n) {
            'use strict';

            var i = n('17b8');
            n.n(i).a;
        },
        '17b8': function (t, e, n) {},
        '1b99': function (t, e, n) {
            'use strict';

            n.r(e);
            var i = n('946c');
            var o = n('9938');
            for (var u in o) {
                if (['default'].indexOf(u) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return o[t];
                        });
                    })(u);
                }
            }
            n('084b');
            var r = n('f0c5');
            var c = Object(r.a)(o.default, i.b, i.c, false, null, '0eb2e4ce', null, false, i.a, void 0);
            e.default = c.exports;
        },
        '50c1': function (t, e, n) {
            'use strict';

            (function (t, e) {
                var i = n('4ea4');
                n('18ba');
                i(n('66fd'));
                var o = i(n('1b99'));
                t.__webpack_require_UNI_MP_PLUGIN__ = n;
                e(o.default);
            }.call(this, n('bc2e').default, n('543d').createPage));
        },
        8585: function (t, e, n) {
            'use strict';

            (function (t) {
                var i = n('4ea4');
                Object.defineProperty(e, '__esModule', {
                    value: true
                });
                e.default = void 0;
                var o = i(n('9523'));
                function u(t, e) {
                    var n = Object.keys(t);
                    if (Object.getOwnPropertySymbols) {
                        var i = Object.getOwnPropertySymbols(t);
                        if (e) {
                            i = i.filter(function (e) {
                                return Object.getOwnPropertyDescriptor(t, e).enumerable;
                            });
                        }
                        n.push.apply(n, i);
                    }
                    return n;
                }
                function r(t) {
                    for (var e = 1; e < arguments.length; e++) {
                        if (null != arguments[e]) {
                            var n = arguments[e];
                        } else {
                            var n = {};
                        }
                        if (e % 2) {
                            u(Object(n), true).forEach(function (e) {
                                (0, o.default)(t, e, n[e]);
                            });
                        } else {
                            Object.getOwnPropertyDescriptors
                                ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n))
                                : u(Object(n)).forEach(function (e) {
                                      Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e));
                                  });
                        }
                    }
                    return t;
                }
                var c = {
                    components: {
                        MyRecordList: function () {
                            n.e('pages/zhuli/components/MyRecordList')
                                .then(
                                    function () {
                                        return resolve(n('590a'));
                                    }.bind(null, n)
                                )
                                .catch(n.oe);
                        }
                    },
                    data: function () {
                        return {
                            isInit: false,
                            uuid: '',
                            isNotFound: false,
                            info: {},
                            launchUuid: '',
                            launchRecord: {},
                            isSharePopup: false,
                            isShowUserGroupCheck: false,
                            userGroupId: '',
                            userGroupTitle: '',
                            isShowMyRecordList: false
                        };
                    },
                    computed: r(
                        r({}, (0, n('26cb').mapGetters)(['userInfo'])),
                        {},
                        {
                            share: function () {
                                var t = this.info.title;
                                if (this.launchRecord.user) {
                                    t = this.launchRecord.user.name + '邀请您来助力~';
                                }
                                return {
                                    path: '/pages/zhuli/detail?uuid=' + this.info.uuid + '&invite_node=zhuli-' + this.info.uuid + '&launchRecordUuid=' + this.launchUuid,
                                    title: t,
                                    thumb: this.info.thumb
                                };
                            },
                            bgImage: function () {
                                return 'https://cdn2.hquesoft.com/box/zhuli/bg.png';
                            },
                            sku: function () {
                                return (this.info.skus && this.info.skus[0]) || {};
                            },
                            userList: function () {
                                for (
                                    t = [],
                                        e = {
                                            headimg: 'https://cdn2.hquesoft.com/box/default-headimg'
                                        },
                                        n = 0,
                                        void 0;
                                    n < this.info.need_user_total;
                                    n++
                                ) {
                                    var t;
                                    var e;
                                    var n;
                                    var i = (this.launchRecord.support_records && this.launchRecord.support_records[n] && this.launchRecord.support_records[n].user) || e;
                                    t.push(i);
                                }
                                return t;
                            },
                            posterInfo: function () {
                                var t = this.getShareConfig(false);
                                var e = '快来帮我助力赢礼品吧~';
                                if (this.launchRecord.user) {
                                    e = this.launchRecord.user.name + '邀请您来助力~';
                                }
                                return {
                                    title: e,
                                    path: this.getShareConfig().path,
                                    thumb: this.info.thumb,
                                    app_url: t.app_url
                                };
                            }
                        }
                    ),
                    watch: {},
                    onLoad: function (e) {
                        var that = this;
                        this.uuid = e.uuid;
                        this.launchUuid = e.launchRecordUuid;
                        t.showLoading({
                            title: '加载中'
                        });
                        this.initData()
                            .then(function (e) {
                                that.isInit = true;
                                t.hideLoading();
                            })
                            .catch(function (t) {
                                if (404 == t.statusCode) {
                                    that.isNotFound = true;
                                }
                            });
                    },
                    onShow: function () {
                        var that = this;
                        if (this.isInit) {
                            this.initData()
                                .then(function (e) {
                                    that.isInit = true;
                                })
                                .catch(function (e) {
                                    if (404 == e.statusCode) {
                                        that.isNotFound = true;
                                    }
                                });
                        }
                    },
                    methods: {
                        selectLaunchRecord: function (t) {
                            var that = this;
                            this.launchUuid = t.uuid;
                            this.isShowMyRecordList = false;
                            this.$http('/zhuli/launch-records/' + this.launchUuid).then(function (t) {
                                that.launchRecord = t.data.info;
                            });
                        },
                        checkMyRecord: function () {
                            this.isShowMyRecordList = true;
                        },
                        checkLaunchUserGroup: function () {
                            this.userGroupTitle = '发起助力';
                            this.userGroupId = this.info.launch_user_group_id;
                            this.isShowUserGroupCheck = true;
                        },
                        checkSupportUserGroup: function () {
                            this.userGroupTitle = '给他人助力';
                            this.userGroupId = this.info.support_user_group_id;
                            this.isShowUserGroupCheck = true;
                        },
                        sharePage: function () {
                            this.isSharePopup = true;
                        },
                        initData: function () {
                            var that = this;
                            if (this.launchUuid) {
                                this.$http('/zhuli/launch-records/' + this.launchUuid).then(function (t) {
                                    that.launchRecord = t.data.info;
                                });
                            }
                            return this.$http('/zhuli/activities/'.concat(this.uuid)).then(function (n) {
                                that.info = n.data.info;
                                that.prizeList = that.info.skus.map(function (t) {
                                    return {
                                        prizeId: t.id,
                                        prizeName: t.title,
                                        prizeStock: t.stock,
                                        prizeWeight: t.id,
                                        prizeImage: t.thumb + '?x-oss-process=image/resize,w_200'
                                    };
                                });
                                t.setNavigationBarTitle({
                                    title: n.data.info.title
                                });
                            });
                        },
                        launchActivity: function () {
                            var that = this;
                            var n = '发起助力';
                            if (this.info.score_price) {
                                n = '支付' + this.info.score_price + this.scoreAlias + '发起助力';
                            }
                            t.showModal({
                                title: n,
                                content: '发起后需要在' + this.info.time_limit + '小时内集齐' + this.info.need_user_total + '助力才算完成哦~',
                                confirmText: '立即发起',
                                success: function (n) {
                                    if (n.confirm) {
                                        t.showLoading({
                                            title: '加载中~'
                                        });
                                        that.$http('/zhuli/launch-records', 'POST', {
                                            activity_id: that.info.id
                                        }).then(function (n) {
                                            t.hideLoading();
                                            that.launchUuid = n.data.uuid;
                                            that.initData();
                                        });
                                    }
                                }
                            });
                        },
                        createSupport: function () {
                            var that = this;
                            t.showLoading({
                                title: '助力中~'
                            });
                            this.$http('/zhuli/support-records', 'POST', {
                                launch_record_id: this.launchRecord.id
                            }).then(function (n) {
                                t.hideLoading();
                                that.initData();
                            });
                        }
                    }
                };
                e.default = c;
            }.call(this, n('543d').default));
        },
        '946c': function (t, e, n) {
            'use strict';

            n.d(e, 'b', function () {
                return o;
            });
            n.d(e, 'c', function () {
                return u;
            });
            n.d(e, 'a', function () {
                return i;
            });
            var i = {
                CountDown: function () {
                    return n.e('components/CountDown/CountDown').then(n.bind(null, '2fed'));
                },
                PageRender: function () {
                    return Promise.all([n.e('common/vendor'), n.e('components/PageRender/PageRender')]).then(n.bind(null, 'b4aa'));
                },
                UserGroupCheck: function () {
                    return n.e('components/UserGroupCheck/UserGroupCheck').then(n.bind(null, 'add4'));
                },
                SharePopup: function () {
                    return Promise.all([n.e('common/vendor'), n.e('components/SharePopup/SharePopup')]).then(n.bind(null, 'b677'));
                }
            };
            var o = function () {
                var that = this;
                var e = (that.$createElement, that._self._c, that.launchRecord.id ? that.$tool.formatDate(that.launchRecord.launched_at, 'MM-dd hh:mm') : null);
                that._isMounted ||
                    ((that.e0 = function (e) {
                        that.isShowMyRecordList = false;
                    }),
                    (that.e1 = function (e) {
                        that.isShowUserGroupCheck = false;
                    }),
                    (that.e2 = function (e) {
                        that.isSharePopup = false;
                    }));
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            g0: e
                        }
                    }
                );
            };
            var u = [];
        },
        9938: function (t, e, n) {
            'use strict';

            n.r(e);
            var i = n('8585');
            var o = n.n(i);
            for (var u in i) {
                if (['default'].indexOf(u) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return i[t];
                        });
                    })(u);
                }
            }
            e.default = o.a;
        }
    },
    [['50c1', 'common/runtime', 'common/vendor']]
]);
</script>
<style>
@import './detail.css';
</style>
